
# #基本捕获语法
# try:
#     f = open("E:\\py代码\\abc.txt", "r", encoding="utf-8")
# except:
#     print("出现异常")
#     f = open("E:\\py代码\\abc.txt", "w", encoding="utf-8")
#
# #捕获指定的异常
# try:
#     print(name)
# except NameError as e:
#     print("出现了未定义的异常")
#     print(e)
#
# #捕获多个异常
# try:
#     1 / 0
# except (NameError,ZeroDivisionError) as e:
#     print("出现了未定义的异常或者除以0的异常错误")
#     print(e)

#捕获全部异常
try:
   1 / 1
except Exception as e:
    print("出现异常")
    print(e)
else:
    print("没有出现异常")
finally:
    print("这是必须要执行的")